package ua.kpi.javatraining.university;

/**
 * @author Vasily Yatsenko
 */
public class Student extends Person {
    private int course;
    private LimitedGroup group;

    public Student(Name name, Origin origin, Contacts contacts) {
        super(contacts, origin, name);
        course = 0;
        group = null;
    }

    public int getCourse() {
        return course;
    }

    public void setCourse(int course) {
        this.course = course;
    }

    public LimitedGroup getGroup() {
        return group;
    }

    public void setGroup(LimitedGroup group) {
        this.group = group;
    }

    public String getCurriculum() {
        return group.getUniversity().getCurriculum(this);
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if ((obj == null) || (obj.getClass() != this.getClass())) {
            return false;
        }
        Student other = (Student) obj;

        return this.getName().equals(other.getName());
    }

    @Override
    public String toString() {
        StringBuilder builder = new StringBuilder();

        builder.append(super.toString());
        builder.append("Course: ");
        builder.append(getCourse());
        builder.append(". Group ");
        if (getGroup() == null) {
            builder.append("none");
        } else {
            builder.append(getGroup().getName());
        }
        builder.append(".");
        return builder.toString();
    }
}
